package net.oktaeder.office.utils.ordertransformer;

import java.util.ArrayList;
import java.util.Hashtable;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import net.oktaeder.office.model.WorkOrder;
import net.oktaeder.office.model.WorkOrderData;
import net.oktaeder.office.view.Mail;

public class PersonalMailTransformer implements IMailTransformer {

	private static Log log = LogFactory.getLog(PersonalMailTransformer.class);
	
	public Hashtable<String, ArrayList<WorkOrder>> TransformMail(Mail mail) {
		// TODO Auto-generated method stub
		String recepient;
		Hashtable<String, ArrayList<WorkOrder>> workOrderCollection;
		ArrayList<WorkOrder> workOrders;
		WorkOrder workOrder;
		
		recepient = mail.getRecepient();
		workOrder = new WorkOrder();
		workOrders = new ArrayList<WorkOrder>();
		workOrderCollection = new Hashtable<String, ArrayList<WorkOrder>>();
		
		if (mail.getMessage().contains("fired")) {
			workOrder.addValue("action", "fired");
			workOrder.setOrderType(WorkOrderData.OrderType.PersonalOrder);
		}
		
		workOrders.add(workOrder);
		workOrderCollection.put(recepient, workOrders);
		
		return workOrderCollection;
		
	}
}
